package com.game.view.component
{
	import com.dusk.util.ResUtil;
	import com.greensock.TweenMax;
	
	import flash.display.MovieClip;
	
	public class BeAttackTimeBar extends ComponentBase
	{
		public function BeAttackTimeBar()
		{
		}
		
		private var bar:MovieClip;
		
		override protected function beforeAdded():void
		{
			var mc:MovieClip = ResUtil.getComponentView("BeAttTimeBar") as MovieClip;
			bar = mc.getChildByName("ruler") as MovieClip;
			addChild(mc);
		}
		
		public function update(scale:Number,duration:Number = 0.2):void
		{
			if(scale > 1) scale = 1;
			if(scale < 0) scale = 0;
			if(TweenMax.isTweening(bar))
			{
				TweenMax.killTweensOf(bar);
			}
			TweenMax.to(bar,duration,{scaleX:scale})
		}
		
		public function clear():void
		{
			TweenMax.killTweensOf(bar);
			bar.scaleX = 0;
		}
	}
}
